package com.yanqu.road.server.cmd.activity.gashapon;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.GashaponProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.gashapon.CrossGashaponMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

/**
 * @Author : Cxp
 * @Time : 2024-10-23
 * @Description : 幸运扭蛋-跨服获取公告
 */

@Cmd(code = CrossProtocol.C_GASHAPON_GET_NOTICE, desc = "跨服获取公告")
public class CrossGashaponGetNoticeCmd extends CrossCommand {

    private int activityId;


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        GashaponProto.CrossGashaponGetNoticeReq reqMsg = GashaponProto.CrossGashaponGetNoticeReq.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        GashaponProto.GashaponNoticeMsgResp.Builder activityNoticeMsg = CrossGashaponMgr.getActivityNoticeMsg(activityId);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(ClientProtocol.U_GASHAPON_GET_NOTICE, activityNoticeMsg);
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), pbMsg);
    }

    @Override
    public void sendData() {

    }
}
